package phrase1;

import java.util.Vector;

public class DictionaryChecking {

	public boolean check(String s)
	{
		char extractStringResult =  extractString(s);
		String extractVectorResult;

		dictionary d = new dictionary();
		d.setindex(extractStringResult);
		Vector<String> v = d.getAll();

		extractVectorResult = extractVector(v, s);

		if(s.equalsIgnoreCase(extractVectorResult))
		{
			return true;
		}
		else 
		{
			return false;
		}	
	}

	public char extractString(String s)
	{
		return s.charAt(0);
	}

	public String extractVector(Vector<String> v, String s)
	{
		String temp = null;
		int tempInt  = v.size();
		int i = 0;
		while(!(s.equalsIgnoreCase(v.get(i))) && (i < tempInt))
		{
			int nextIndex = i+1;
			if (s.equalsIgnoreCase(v.get(i)))
				{
					temp = v.get(nextIndex);
				}
			else
				i++;
		}
		return temp;
	}
}
